﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class Venue : LastfmModelBase, IHasFiveImages
    {
        public Venue()
        {
            this.Id = 0;
            this.Name = string.Empty;
            this.Location = new Location();
            this.Url = string.Empty;
            this.Website = string.Empty;
            this.PhoneNumber = string.Empty;
            this.ImageSmall = string.Empty;
            this.ImageMedium = string.Empty;
            this.ImageLarge = string.Empty;
            this.ImageExtralarge = string.Empty;
            this.ImageMega = string.Empty;
        }

        public Venue(XmlNode venueNode)
        : this()
        {
            if (venueNode == null) return;
            this.InitializeFromXmlNode(venueNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.Id = node.GetChildValue("id").ToInteger();
            this.Name = node.GetChildValue("name");
            this.Location = new Location(node.GetChild("location"));
            this.Url = node.GetChildValue("url");
            this.Website = node.GetChildValue("website");
            this.PhoneNumber = node.GetChildValue("phonenumber");
            this.ImageSmall = node.GetChildValueWithSpecialAtrribute("image", "size", "small");
            this.ImageMedium = node.GetChildValueWithSpecialAtrribute("image", "size", "medium");
            this.ImageLarge = node.GetChildValueWithSpecialAtrribute("image", "size", "large");
            this.ImageExtralarge = node.GetChildValueWithSpecialAtrribute("image", "size", "extralarge");
            this.ImageMega = node.GetChildValueWithSpecialAtrribute("image", "size", "mega");
        }

        public int Id { get; set; }

        public string Name { get; set; }

        public Location Location { get; set; }

        public string Url { get; set; }

        public string Website { get; set; }

        public string PhoneNumber { get; set; }

        public string ImageSmall { get; set; }

        public string ImageMedium { get; set; }

        public string ImageLarge { get; set; }

        public string ImageExtralarge { get; set; }

        public string ImageMega { get; set; }
    }
}
